//
//  SecondRootViewController.m
//  lzzHHHH
//
//  Created by lanou3g on 15/12/9.
//  Copyright (c) 2015年 hy. All rights reserved.
//

#import "SecondRootViewController.h"

@interface SecondRootViewController ()

@end

@implementation SecondRootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self CreateSgementController];
}

-(void)CreateSgementController{
    self.one = [[SecondOneTableViewController alloc]init];
    self.two = [[SecondTwoTableViewController alloc]init];
    [self.view addSubview:self.one.view];
    [self.view bringSubviewToFront:self.segmentControl];
    [self.segmentControl addTarget:self action:@selector(actionSegmentControl:) forControlEvents:UIControlEventValueChanged];
    
}

-(void)actionSegmentControl:(UISegmentedControl *)sender{
    switch (sender.selectedSegmentIndex) {
        case 0:
            if (self.one.view.superview == nil) {
                [self.two.view removeFromSuperview];
                [self.view addSubview:self.one.view];
                [self.view bringSubviewToFront:self.segmentControl];
            }
            break;
        case 1:
            if (self.two.view.superview == nil) {
                [self.one.view removeFromSuperview];
                [self.view addSubview:self.two.view];
                [self.view bringSubviewToFront:self.segmentControl];
            }
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
